import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";

var _dec, _class;

import React from 'react';
import { Modal, Table } from 'antd';
import { Bind } from 'lodash-decorators';
import { Button as ButtonPermission } from 'components/Permission';
import { createPagination } from 'utils/utils';
import intl from 'utils/intl';
/**
 * 接收人数据展示列表
 * @extends {PureComponent} - React.PureComponent
 * @reactProps {Function} onChange - 分页查询
 * @reactProps {Boolean} loading - 数据加载完成标记
 * @reactProps {Array} dataSource - Table数据源
 * @reactProps {Object} pagination - 分页器
 * @reactProps {Object} recipientData - 收件人信息
 * @reactProps {Number} pagination.current - 当前页码
 * @reactProps {Number} pagination.pageSize - 分页大小
 * @reactProps {Number} pagination.total - 数据总量
 * @return React.element
 */

var RecipientView = (_dec = Bind(), (_class = /*#__PURE__*/function (_React$PureComponent) {
  _inherits(RecipientView, _React$PureComponent);

  var _super = _createSuper(RecipientView);

  function RecipientView() {
    _classCallCheck(this, RecipientView);

    return _super.apply(this, arguments);
  }

  _createClass(RecipientView, [{
    key: "changeTablePagination",
    value: // 收件人表格分页
    function changeTablePagination(pagination) {
      var _this$props = this.props,
          recordData = _this$props.recordData,
          onOpenRecipientModal = _this$props.onOpenRecipientModal;

      var params = _objectSpread(_objectSpread({}, recordData), {}, {
        page: pagination.current - 1,
        size: pagination.pageSize
      });

      onOpenRecipientModal(params);
    }
  }, {
    key: "render",
    value: function render() {
      var _this$props2 = this.props,
          recipientVisible = _this$props2.recipientVisible,
          onOk = _this$props2.onOk,
          recipientData = _this$props2.recipientData,
          loading = _this$props2.loading,
          path = _this$props2.path;
      var columns = [{
        title: intl.get('cmsg.messageQuery.model.messageQuery.receiverAddress').d('收件人地址'),
        dataIndex: 'receiverAddress'
      }];
      return /*#__PURE__*/React.createElement(Modal, {
        title: intl.get('cmsg.messageQuery.model.messageQuery.receiver').d('接收人'),
        width: 520,
        destroyOnClose: true,
        visible: recipientVisible,
        closable: false,
        footer: /*#__PURE__*/React.createElement(ButtonPermission, {
          permissionList: [{
            code: "".concat(path, ".button.saveRecipient"),
            type: 'button',
            meaning: '消息查询-接收者确定'
          }],
          type: "primary",
          onClick: onOk
        }, intl.get('cpaas.common.button.sure').d('确定'))
      }, /*#__PURE__*/React.createElement(Table, {
        bordered: true,
        rowKey: "receiverId",
        dataSource: loading ? [] : recipientData.content || [],
        columns: columns,
        loading: loading,
        pagination: createPagination(recipientData),
        onChange: this.changeTablePagination
      }));
    }
  }]);

  return RecipientView;
}(React.PureComponent), (_applyDecoratedDescriptor(_class.prototype, "changeTablePagination", [_dec], Object.getOwnPropertyDescriptor(_class.prototype, "changeTablePagination"), _class.prototype)), _class));
export { RecipientView as default };